﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    function openFormUpload() {
        $.ajax({
            type: "GET",
            url: "/Form/FormUpload",
            success: function(data) {
                addtab('11-2', '上传表单');
                $("#workarea-11-2").html(data);
            }
        })
    }
    $(function() {
        tableSelectOrder("#formlist .table_style");
    })

    function formshow(form_id) {
        $.ajax({
            type: "POST",
            url: "/Form/FormShow",
            data: { "form_id": form_id },
            success: function(data) {
                $("#workarea-11-1").html(data);
            }
        })
    }
</script>

<div id="formlist">
    <input class="btn_style" type="button" value="上传表单" onclick="openFormUpload()" style="margin-top: 5px;" />
    <div style="margin-top: 5px;">
        <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th>
                        表单名称
                    </th>
                    <th>
                        创建人
                    </th>
                    <th>
                        创建时间
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    System.Data.DataTable dt_forms = ViewData["dt_forms"] as System.Data.DataTable;

                    if (dt_forms.Rows == null || dt_forms.Rows.Count == 0)
                    {%>
                <tr>
                    <td colspan="0" style="text-align: center;">
                        当前无数据！
                    </td>
                </tr>
                <%
                    }
                    else
                    {
                        int count = dt_forms.Rows.Count;
                        for (int i = 0; i < count; i++)
                        {
                %>
                <tr>
                    <td>
                        <%=dt_forms.Rows[i]["表单名称"]%>
                    </td>
                    <td>
                        <%=dt_forms.Rows[i]["创建人"]%>
                    </td>
                    <td>
                        <%=DateTime.Parse(dt_forms.Rows[i]["创建时间"].ToString()).ToString("yyyy-MM-dd HH:mm")%>
                    </td>
                    <td>
                        <a onclick="formshow(<%=dt_forms.Rows[i]["编码"] %>)">查看</a>
                    </td>
                </tr>
                <%
                    }
                    } %>
            </tbody>
        </table>
    </div>
    <div id="pageLink">
        <%var pageInfo = ViewData["pageInfo"] as PagingInfo; %>
        <%if (pageInfo != null)
          { %>
        <%=Ajax.PageLinks(pageInfo, index => Url.Action("FormList", new { page = index }), new AjaxOptions { UpdateTargetId = "workarea-11-1" })%>
        <%} %>
    </div>
</div>
